import hashlib


def main():
    # 创建对象
    digester = hashlib.md5()  # 哈希摘要，MD5大小128比特，16进制是32长度
    # 以二进制读取
    with open('H:/软件/python/Python-3.7.8.tar.xz', 'rb') as file_stream:
        file_iter = iter(lambda: file_stream.read(1024), b'')  # b''空字节，''空字符串
        for data in file_iter:
            digester.update(data)
        # data = file_stream.read(1024)
        # while data:
        #     digester.update(data)
        #     data = file_stream.read(1024)
    # digester.update(b'1234QWEasd')
    print(digester.hexdigest())


if __name__ == '__main__':
    main()
